package com.hjm.project.TransactionAccumulation.zlCashDetails.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.TransactionAccumulation.zlCashDetails.domain.ZlCashDetails;
import com.hjm.project.TransactionAccumulation.zlCashDetails.service.IZlCashDetailsService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

import javax.annotation.Resource;

/**
 * 增量返现明细Controller
 * 
 * @author maker-platform
 * @date 2021-07-07
 */
@Controller
@RequestMapping("/zlCashDetails/zlCashDetails")
public class ZlCashDetailsController extends BaseController
{
    private String prefix = "transactionAccumulation/zcd";

    @Resource
    private IZlCashDetailsService zlCashDetailsService;

    @RequiresPermissions("zlCashDetails:zlCashDetails:view")
    @GetMapping()
    public String zlCashDetails()
    {
        return prefix + "/zcd";
    }

    /**
     * 查询增量返现明细列表
     */
    @RequiresPermissions("zlCashDetails:zlCashDetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZlCashDetails zlCashDetails)
    {
        startPage();
        List<ZlCashDetails> list = zlCashDetailsService.selectZlCashDetailsList(zlCashDetails);
        return getDataTable(list);
    }

    /**
     * 导出增量返现明细列表
     */
    @RequiresPermissions("zlCashDetails:zlCashDetails:export")
    @Log(title = "增量返现明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZlCashDetails zlCashDetails)
    {
        List<ZlCashDetails> list = zlCashDetailsService.selectZlCashDetailsList(zlCashDetails);
        ExcelUtil<ZlCashDetails> util = new ExcelUtil<ZlCashDetails>(ZlCashDetails.class);
        return util.exportExcel(list, "zlCashDetails");
    }

    /**
     * 新增增量返现明细
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存增量返现明细
     */
    @RequiresPermissions("zlCashDetails:zlCashDetails:add")
    @Log(title = "增量返现明细", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZlCashDetails zlCashDetails)
    {
        return toAjax(zlCashDetailsService.insertZlCashDetails(zlCashDetails));
    }

    /**
     * 修改增量返现明细
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        ZlCashDetails zlCashDetails = zlCashDetailsService.selectZlCashDetailsById(id);
        mmap.put("zlCashDetails", zlCashDetails);
        return prefix + "/edit";
    }

    /**
     * 修改保存增量返现明细
     */
    @RequiresPermissions("zlCashDetails:zlCashDetails:edit")
    @Log(title = "增量返现明细", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZlCashDetails zlCashDetails)
    {
        return toAjax(zlCashDetailsService.updateZlCashDetails(zlCashDetails));
    }

    /**
     * 删除增量返现明细
     */
    @RequiresPermissions("zlCashDetails:zlCashDetails:remove")
    @Log(title = "增量返现明细", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zlCashDetailsService.deleteZlCashDetailsByIds(ids));
    }
}
